import requests
from lxml import etree
from 爬虫.chaojiying import Chaojiying_Client
url='http://www.chaojiying.com/user/login/'
header={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'}
page_text = requests.get(url=url,headers=header).text
tree=etree.HTML(page_text)
img_src='http://www.chaojiying.com/'+tree.xpath('/html/body/div[3]/div/div[3]/div[1]/form/div/img/@src')[0]
img = requests.get(url=img_src,headers=header).content
with open('code.jpg' , 'wb') as fp:
    fp.write(img)
chaojiying=Chaojiying_Client('biubiuboss','091422zhuo','921892')
im = open('code.jpg' , 'rb').read( )
pic_str=chaojiying.PostPic(im,1902)['pic_str']
print(pic_str)
dic={'user':"biubiuboss",'pass':"091422zhuo",'imgtxt':pic_str,'act':'1'}
res = requests.post(url=url,headers=header,data=dic)
print(res.status_code)



